HTML Mohammed Alhessi M.Sc. Geomatics Engineering Wednesday, February 18, 2015 Eng. Mohammed Alhessi 1
W3Schools Main Reference: http://www.w3schools.com/ 2
What is HTML? HTML is a markup language for describing web documents (web pages). HTML stands for Hyper Text Markup Language A markup language is a set of markup tags HTML documents are described by HTML tags Each HTML tag describes different document content 3
Small HTML document 4
Output 5
Example Explained The DOCTYPE declaration defines the document type to be HTML The text between <html> and </html> describes an HTML document The text between <head> and </head> provides information about the document The text between <title> and </title> provides a title for the document The text between <body> and </body> describes the visible page content The text between <h1> and </h1> describes a heading The text between <p> and </p> describes paragraph Using this description, a web browser can display a document with a heading and a paragraph. 6
HTML Tags HTML tags are keywords (tag names) surrounded by angle brackets: <tagname>content</tagname> HTML tags normally come in pairs like <p> and </p> The first tag in a pair is the start tag, the second tag is the end tag The end tag is written like the start tag, but with a slash before the tag name The start tag is often called the opening tag. The end tag is often called the closing tag. 7
Web Browsers The purpose of a web browser (Chrome, IE, Firefox, Safari) is to read HTML documents and display them. The browser does not display the HTML tags, but uses them to determine how to display the document: 8
HTML Page Structure 9
The <!DOCTYPE> Declaration The <!DOCTYPE> declaration helps the browser to display a web page correctly. There are different document types on the web. To display a document correctly, the browser must know both type and version. The doctype declaration is not case sensitive. All cases are acceptable: 10
Common Declarations 11
HTML Versions 12
HTML Editor HTML can be edited by using a professional HTML editor like: Adobe Dreamweaver Let s try it now Microsoft Expression Web CoffeeCup HTML Editor Text Editor: Notepad However, for learning HTML we recommend a text editor like Notepad (PC) or TextEdit (Mac). We believe using a simple text editor is a good way to learn HTML. 13
HTML Elements HTML elements are written with a start tag, with an end tag, with the content in between: <tagname>content</tagname> The HTML element is everything from the start tag to the end tag: <p>my first HTML paragraph.</p> 14
Nested HTML Elements HTML elements can be nested (elements can contain elements). All HTML documents consist of nested HTML elements. This example contains 4 HTML elements: 15
Don't Forget the End Tag Some HTML elements will display correctly, even if you forget the end tag: 16
Empty HTML Elements HTML elements with no content are called empty elements. <br> is an empty element without a closing tag (the <br> tag defines a line break). Empty element can be "closed" in the opening tag like this: <br />. HTML5 does not require empty elements to be closed. But if you need stricter validation, and make your document readable by XML parsers, please close all HTML elements. 17
HTML Tip: Use Lowercase Tags HTML tags are not case sensitive: <P> means the same as <p>. The HTML5 standard does not require lowercase tags, but W3C recommends lowercase in HTML4, and demands lowercase for stricter document types like XHTML. At W3Schools they always use lowercase tags. 18
HTML Attributes HTML elements can have attributes Attributes provide additional information about an element Attributes are always specified in the start tag Attributes come in name/value pairs like: name="value" 19
The lang Attribute The document language can be declared in the <html> tag. The language is declared in the lang attribute. Declaring a language is important for accessibility applications (screen readers) and search engines: 20
The title Attribute HTML paragraphs are defined with the <p> tag. When you move the mouse over the element, the title will be displayed as a tooltip. In this example, the <p> element has a title attribute. The value of the attribute is "About W3Schools": 21
The href Attribute HTML links are defined with the <a> tag. The link address is specified in the href attribute: 22
Size Attributes HTML images are defined with the <img> tag. The filename of the source (src), and the size of the image (width and height) are all provided as attributes The image size is specified in pixels: width="104" means 104 screen pixels wide. 23
W3Schools Suggests: Always Use Lowercase Attributes W3Schools Suggests: Always Quote Attribute Values 24
Headings Headings are defined with the <h1> to <h6> tags. <h1> defines the most important heading. <h6> defines the least important heading. 25
Headings Are Important Use HTML headings for headings only. Don't use headings to make text BIG or bold. Search engines use your headings to index the structure and content of your web pages. Users skim your pages by its headings. It is important to use headings to show the document structure. h1 headings should be main headings, followed by h2 headings, then the less important h3, and so on. 26
HTML Horizontal Rules The <hr> tag creates a horizontal line in an HTML page. The hr element can be used to separate content: 27
The HTML <head> Element The HTML <head> element has nothing to do with HTML headings. The HTML <head> element contains meta data. Meta data are not displayed. The HTML <head> element is placed between the <html> tag and the <body> tag: 28
The HTML <meta> element is also meta data. It can be used to define the character set, and other information about the HTML document. In the chapter about HTML styles you discover more meta elements: The HTML <style> element is used to define internal CSS style sheets. The HTML <link> element is used to define external CSS style sheets. 29
HTML Paragraphs The HTML <p> element defines a paragraph. 30
31
The Poem Problem 32
The HTML <pre> Element 33
HTML Styling Every HTML element has a default style (background color is white, text color is black, text-size is 12px...) Changing the default style of an HTML element, can be done with the style attribute. This example changes the default background color from white to lightgrey: 34
The HTML Style Attribute The HTML style attribute has the following syntax: The property is a CSS property. The value is a CSS value. 35
HTML Text Color The color property defines the text color to be used for an HTML element: 36
HTML Text Fonts The font-family property defines the font to be used for an HTML element: 37
HTML Text Size The font-size property defines the text size to be used for an HTML element: 38
HTML Text Alignment The text-align property defines the horizontal text alignment for an HTML element: 39
HTML Comment Tags You can add comments to your HTML source by using the following syntax: <!-- Write your comments here --> 40
HTML Styles - CSS 41
Assignment01 Install Dreamweaver Prepare ideas for you project. Deadline: next week Practice the examples in the lecture notes 42
Assignment 02 43
References http://www.w3schools.com/ 44